package call4paper;

import java.util.Vector;

import exception.AllRevisedException;
import exception.DoesNotUploadPaperJobException;
import website.User;

public class CFP {
	
	private User creator;
	private String name;
	private CFPState cfpState = new ReceptionState();
	private Vector<InterestArea> interestedAreas = new Vector<InterestArea>();
	private Vector<User> revisors = new Vector<User>();
	private Vector<PaperJob> paperJobs = new Vector<PaperJob>();
	
	public CFP(User author, String name, Vector<InterestArea> intAreas, Vector<User> revisors){
		this.creator = author;
		this.name = name;
		this.interestedAreas.addAll(intAreas);
		this.revisors.addAll(revisors);
	}		
	
	public void setStatus(){
		this.cfpState.setFinalStatusState(this.paperJobs);
	}
	
	public void checkDeadLine() {
		try {
			if(this.cfpState.checkDeadLine())
				this.setStatus();
				this.cfpState = this.cfpState.nextStates();
		} catch (AllRevisedException e) {}
			
	}
	
	public Vector<PaperJob> checkAssignationCFP(User user) {
		return this.cfpState.checkAsignationCFP(this, user);
	}
	
	public void uploadPaperJob(PaperJob aJob) throws DoesNotUploadPaperJobException {
		this.cfpState.uploadPaperJob(aJob, this);
	}
	
	/**********************GETTER AND SETTER************************/

	public User getAuthor() {
		return creator;
	}

	public void setAuthor(User author) {
		this.creator = author;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Vector<InterestArea> getInterestedAreas() {
		return interestedAreas;
	}

	public void setInterestedAreas(Vector<InterestArea> interestedAreas) {
		this.interestedAreas = interestedAreas;
	}

	public Vector<User> getRevisors() {
		return revisors;
	}

	public void setRevisors(Vector<User> revisors) {
		this.revisors = revisors;
	}
	
	public boolean isRevisor(User user) {
		return this.getRevisors().contains(user);
	}

	public Vector<PaperJob> getPaperJobs() {
		return paperJobs;
	}

	public void setPaperJobs(Vector<PaperJob> paperJobs) {
		this.paperJobs = paperJobs;
	}


}
